home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1984 July to December / Ahoy_Magazine_84-Jul-Dec_1984_Double_L_unofficial.d64 / emerald elephant (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  15KB  |  430 lines

  1. 1 rem "the emerald elephant of cipangu"
  2. 2 rem a mini-adventure, just to show how it's done.  for the 64--it won't fit
  3. 3 rem on an unexpanded vic.  if you have an expanded vic, change the text so it
  4. 4 rem will fit properly on the screen.
  5. 5 rem
  6. 6 rem rd=room direction table.  cw$=command word table.  rn$=room names
  7. 7 rem ks=keystroke table.  tn$="thing" name table.  ts$="thing" short names
  8. 8 rem tl="thing" location table (room #).  vs=visit table: non-zero if visited.
  9. 9 rem
  10. 10 dim rd(14,8),cw$(16),rn$(60),ks(64),tn$(9),ts$(9),tl(9),vs(14)
  11. 20 gosub 1000
  12. 25 gosub 970
  13. 27 rem
  14. 28 rem set up blank lines and position strings
  15. 29 rem
  16. 30 bl$="                   "
  17. 31 rl$="":for i=1 to 78:rl$=rl$+" ":next:rl$=rl$+""
  18. 32 tl$="":for i=1 to 78:tl$=tl$+" ":next:tl$=tl$+""
  19. 33 dl$=""
  20. 34 t$="   within your reach is . . . ."
  21. 35 c$=chr$(13)
  22. 60 print "[147]careful!"c$c$"just through those trees is the castle"
  23. 61 print "of darkness."c$c$"once you see it, you'll be struck blind"
  24. 62 print "until you leave."c$c$"but hidden in a secret treasure room"
  25. 63 print "somewhere in the castle is the emerald"
  26. 64 print "elephant of cipangu.  the touch of the"
  27. 65 print "elephant will give you the priceless"
  28. 66 print "gift of far sight, which will let you"
  29. 67 print "see to the ends of the earth.  whatever"
  30. 68 print "place you think of, you will see."c$c$"(press any key)":gosub 990
  31. 69 print "[147]as for me, i seem to you to be merely a"
  32. 70 print "firefly.  i am really something else"
  33. 71 print "entirely, and once you get the elephant"
  34. 72 print "and leave the castle, you will see me asi really am."c$
  35. 73 print "will you come with me?  i'll be your"
  36. 74 print "eyes, while you decide where we should  go."c$
  37. 75 print "you can press a single key to go u[154]p,"
  38. 76 print "d[154]own, i[154]n, o[154]ut, n[154]orth, s[154]outh, e[154]ast, w[154]est, or b[154]ack."c$
  39. 77 print "you can also t[154]ake something, l[154]eave it"
  40. 78 print "behind, tell me to p[154]eer closely at"
  41. 79 print "things around us, check to see what we"
  42. 80 print "have g[154]ot, q[154]uit, or ask for h[154]elp (?[154])."c$c$"(press any key)"
  43. 81 gosub 990
  44. 87 rem
  45. 88 rem initial position
  46. 89 rem
  47. 90 xx=1:xr=1:pr=1:gosub 350
  48. 97 rem
  49. 98 rem main loop.  get keystroke first
  50. 99 rem
  51. 100 gosub 990
  52. 105 print bl$cw$(cm):if cm=0 then 100
  53. 107 rem
  54. 108 rem direction commands
  55. 109 rem
  56. 110 if cm<9 then gosub 300:goto 130
  57. 117 rem
  58. 118 rem all other commands
  59. 119 rem
  60. 120 c=cm-8:on c gosub 390,400,450,550,470,190,500,500
  61. 127 rem
  62. 128 rem check for victory
  63. 129 rem
  64. 130 if pr=1 and tl(9)=0 then for i=0 to 999:next:goto 940
  65. 140 print bl$cw$(cm):goto 100
  66. 187 rem
  67. 188 rem "quit" routine
  68. 189 rem
  69. 190 print "[147]press q to quit":gosub 990:if cm=14 then end
  70. 195 goto 350
  71. 297 rem
  72. 298 rem movement handler
  73. 299 rem
  74. 300 xx=xr:xr=pr:pr=rd(xr,cm)
  75. 302 rem
  76. 303 rem check for special cases
  77. 304 rem
  78. 310 if xr=7 and tl(0)=0 and pr=56 then gosub 900:pr=1:goto 350
  79. 315 if pr=14 then gosub 905:goto 350
  80. 320 if pr=56 and xr=4 and tl(2)=0 then gosub 920:pr=5:goto 350
  81. 325 if pr=4 and xr=5 and tl(9)=0 then gosub 925:goto 350
  82. 342 rem
  83. 343 rem is it an illegal movement?
  84. 344 rem
  85. 345 ds$="":if pr>49 then ds$=rn$(pr):pr=xr:xr=xx
  86. 346 rem
  87. 347 rem      * * *  return point  * * *
  88. 348 rem table search--are there any "things" in the room?
  89. 349 rem
  90. 350 tn$="":for i=0 to 9:if tl(i)=pr then tn$=tn$+tn$(i)+", "
  91. 355 next:l=len(tn$):if l>1 then tn$=left$(tn$,l-2)
  92. 360 tt$=t$:if tn$="" then tt$=""
  93. 362 rem
  94. 363 rem set room name to present room
  95. 364 rem
  96. 365 rn$=rn$(pr)
  97. 367 rem
  98. 368 rem is it the first visit to the room?
  99. 369 rem
  100. 370 if vs(pr)=0 then vs(pr)=1:goto 550
  101. 372 rem
  102. 373 rem clear screen and print room name and message
  103. 374 rem
  104. 375 print "[147]"cw$(cm)rl$rn$tt$tl$tn$dl$ds$
  105. 380 return
  106. 387 rem
  107. 388 rem back command handler
  108. 389 rem
  109. 390 xx=pr:pr=xr:xr=xx:rn$=rn$(pr):ds$="":goto 350
  110. 397 rem
  111. 398 rem "take" routine
  112. 399 rem
  113. 400 i=0
  114. 405 if tl(i)=pr then tl(i)=0:pp$=pp$+chr$(i):ds$="got it!":goto 350
  115. 410 if len(pp$)>5 then gosub 450
  116. 415 i=i+1:if i>9 then ds$="there's nothing here.":goto 350
  117. 420 goto 405
  118. 447 rem
  119. 448 rem "leave" routine
  120. 449 rem
  121. 450 if len(pp$)<1 then ds$="you don't have anything now.":goto 350
  122. 455 lt=asc(left$(pp$,1)):pp$=right$(pp$,len(pp$)-1)
  123. 460 tl(lt)=pr:ds$="":goto 350
  124. 467 rem
  125. 468 rem "got" handler
  126. 469 rem
  127. 470 if pp$="" then ds$="you've got nothing right now.":goto 350
  128. 475 ds$="you've got:"+c$+c$
  129. 480 for i=1 to len(pp$):ds$=ds$+ts$(asc(mid$(pp$,i,1)))+c$:next
  130. 485 goto 350
  131. 497 rem
  132. 498 rem "help" routine
  133. 499 rem
  134. 500 print "[147]"c$c$"there are 9 possible directions:"
  135. 501 print "n = north"c$"s = south"c$"e = east"c$"w = west"c$"u = up"
  136. 502 print "d = down"c$"i = in"c$"o = out"c$"b = back to previous room"c$
  137. 503 print "other commands are:"c$c$"t = take the first object listed"
  138. 504 print "l = leave behind whatever you've been       carrying longest"
  139. 505 print "p = peer at surroundings"c$"g = list what we've got with us"
  140. 506 print "q = quit"c$"h = help"c$"? = help"c$
  141. 507 print "(press any key)";:gosub 990:print "[147]":goto 350
  142. 547 rem
  143. 548 rem "peer" jump table
  144. 549 rem
  145. 550 print "[147]"dl$
  146. 555 on pr gosub 600,620,640,660,680,700,720,740,760,780,800,820,840,860
  147. 560 print bl$cw$(cm)rl$rn$tt$tl$tn$
  148. 565 return
  149. 597 rem
  150. 598 rem main gate description
  151. 599 rem
  152. 600 print "we are standing on the bridge leading"
  153. 601 print "to the huge wooden gate of the castle."c$
  154. 602 print "to the north is the deep forest.  a"
  155. 603 print "path leads around the castle to the"
  156. 604 print "east and west.  the walls are very high"
  157. 605 print "and i can't see anyone at all."
  158. 615 return
  159. 617 rem
  160. 618 rem west of castle
  161. 619 rem
  162. 620 print "the meadow is full of rabbits, so be"
  163. 621 print "careful where you step.  the forest is"
  164. 622 print "thick to the west.  a path leads around"
  165. 623 print "the castle to the north and south."c$
  166. 624 print "the stones of the castle wall are slick"
  167. 625 print "and covered with moss."c$
  168. 626 print "listen--you can hear a horse whinnying."
  169. 635 return
  170. 637 rem
  171. 638 rem east of castle
  172. 639 rem
  173. 640 print "please don't dance around so much!"c$
  174. 641 print "we're on a narrow ledge along the east"
  175. 642 print "edge of the castle.  it ends just a few"
  176. 643 print "yards to the south."c$
  177. 644 print "over the edge it's a sheer drop for at"
  178. 645 print "least two thousand feet.  the edge is"
  179. 646 print "crumbling a little, so if you don't"
  180. 647 print "mind, couldn't we just go back?"
  181. 655 return
  182. 657 rem
  183. 658 rem south of castle
  184. 659 rem
  185. 660 print "we're in a grove of trees on a narrow"
  186. 661 print "wedge of land just south of the castle."c$
  187. 662 print "the land slopes down toward the founda-"
  188. 663 print "tion of the castle to the north, and to"
  189. 664 print "the south it slopes up to a sudden"
  190. 665 print "drop-off.  there's a steep cliff to the east, too."c$
  191. 666 print "there's a column of smoke rising above  the castle wall."
  192. 675 return
  193. 677 rem
  194. 678 rem kitchen
  195. 679 rem
  196. 680 print "the kitchen fire is burning hotly, but"
  197. 681 print "there's no one in the room."c$
  198. 682 print "a large open doorway leads out into the"
  199. 683 print "courtyard to the north and west.  the"
  200. 684 print "doorway is filled with flies.  not"
  201. 685 print "fireflies--the lower-class kind."c$
  202. 686 print "to the east there's another door, and"
  203. 687 print "to the south there's a gap where one"
  204. 688 print "stone has been pulled out of the"
  205. 689 print "foundation.  it's the secret postern"
  206. 690 print "door, the one we crawled through."c$
  207. 691 print "there's a large table in the middle of"
  208. 692 print "the room, with more food on it than a"
  209. 693 print "normal person could eat in a week.";
  210. 695 return
  211. 697 rem
  212. 698 rem courtyard
  213. 699 rem
  214. 700 print "we're in an open area in the center of"
  215. 701 print "the castle.  the door of the great hall is just east of us."c$
  216. 702 print "the kitchen is to the south and there   are stables to the west."c$
  217. 703 print "to the north is the gatehouse, a thick"
  218. 704 print "building that surrounds and protects themain gate."c$
  219. 705 print "the dirt in the courtyard is smooth, as"
  220. 706 print "if no one had ever walked here. the onlyfootprints are yours."
  221. 715 return
  222. 717 rem
  223. 718 rem gatehouse
  224. 719 rem
  225. 720 print "we're high up in the gatehouse, by the"
  226. 721 print "windlass that controls the gate.  it's"
  227. 722 print "stuck--all your strength can't budge it.sorry i can't help."c$
  228. 723 print "there are short stairways leading up to"
  229. 724 print "the walls, and another stairway leading"
  230. 725 print "down to the courtyard below us."c$
  231. 726 print "hanging from a spike on the wall is a"
  232. 727 print "single elephant's tusk.  it's too high  to reach."
  233. 735 return
  234. 737 rem
  235. 738 rem on the walls
  236. 739 rem
  237. 740 print "we're on the castle walls, behind the"
  238. 741 print "crenellation.  we can walk all the way"
  239. 742 print "around the castle.  the only places we"
  240. 743 print "can get off are the gatehouse and the"
  241. 744 print "tower that rises above the great hall."c$
  242. 745 print "please don't stay up here too long."
  243. 746 print "there are birds coming closer.  they"
  244. 747 print "look to me like the insect-eating kind,"
  245. 748 print "and a firefly like me can't hide very   easily."
  246. 755 return
  247. 757 rem
  248. 758 rem great hall
  249. 759 rem
  250. 760 print "we're in the great hall of the castle."
  251. 761 print "a large doorway in the north leads to"
  252. 762 print "the courtyard, while a small door to  the west goes to the kitchen."
  253. 763 print c$"there are tables and benches around the"
  254. 764 print "room, a huge fire pit in the middle, anda throne at one end."
  255. 765 print c$"a large tapestry on the wall proclaims"
  256. 766 print "that this is the residence of the count of obscurity."c$
  257. 767 print "a small stairway goes up along one wall"
  258. 768 print "and behind the throne there's a trap"
  259. 769 print "door that someone has carelessly left"
  260. 770 print "half open.";
  261. 775 return
  262. 777 rem
  263. 778 rem count's chamber
  264. 779 rem
  265. 780 print "the large curtained bed looks recently"
  266. 781 print "slept in, and the hearth coals are stillglowing."c$
  267. 782 print "small doors lead onto the walls to the"
  268. 783 print "north and west, while small cupboard"
  269. 784 print "doorways seem to lurk behind every"c$"tapestry."c$
  270. 785 print "a stairway in one corner goes down, and"
  271. 786 print "a narrow ladder leads up through the"
  272. 787 print "ceiling.  i think i can hear footsteps"
  273. 788 print "above us.  please don't go up there."
  274. 795 return
  275. 797 rem
  276. 798 rem tower lookout
  277. 799 rem
  278. 800 print "we're at the highest point of the"c$"castle."c$
  279. 802 print "ignore the sound of someone walking"
  280. 803 print "around.  it isn't anybody--just an"
  281. 804 print "empty suit of armor that keeps walking"
  282. 805 print "around and around the edge of the tower."
  283. 806 print "at least i think it's empty."c$
  284. 807 print "would you mind terribly if we just went back down the ladder?"
  285. 815 return
  286. 817 rem
  287. 818 rem the stables
  288. 819 rem
  289. 820 print "the floor of the stable is wooden, and"
  290. 821 print "some of the boards are missing--test"
  291. 822 print "each step before you put your weight on"
  292. 823 print "it.  it looks like a long way down if"
  293. 824 print "you fall through.  or is there somethingunder the stable?":print
  294. 825 print "there's that whinnying sound.  it seems"
  295. 826 print "to be coming from that stall, but the"
  296. 827 print "stall is empty.":print
  297. 828 print "i don't mean to sound timid, but the"
  298. 829 print "only way out of here is the east door tothe courtyard."
  299. 835 return
  300. 837 rem
  301. 838 rem the dungeons
  302. 839 rem
  303. 840 print "we're down in the dungeons, and the"
  304. 841 print "only light down here is me.":print
  305. 842 print "and i'm not all that bright.":print
  306. 843 print "lots of little cells everywhere. mostly"
  307. 844 print "empty.  none of them with any living"
  308. 845 print "residents.  unless you count rats.":print
  309. 846 print "i don't see any death traps, but then, ican't see much of anything."
  310. 855 return
  311. 857 rem
  312. 858 rem the treasure room
  313. 859 rem
  314. 860 print "we made it!  there are coins and ingots and jewels everywhere!"
  315. 861 print:print "paintings, too.  and sculptures.":print
  316. 862 print "no, don't take any of it!  it's all"
  317. 863 print "cursed!  just the elephant of cipangu--"
  318. 864 print "that's all you can take with you, if"
  319. 865 print "you want to live long and prosper."
  320. 875 return
  321. 900 rd(7,1)=1:rd(7,8)=1:rd(1,2)=7:rd(1,7)=7
  322. 901 ds$="using the golden key, you unlock the    turnstile and open the gate"
  323. 902 return
  324. 905 if tl(4)=0 and tl(5)=0 and tl(8)=0 then 910
  325. 906 pr=xr:xr=xx:ds$=rn$(56):return
  326. 910 print "[147]"dl$"don't be so clumsy!  you spilled some"
  327. 911 print "ale from the flagon on the pillow and"
  328. 912 print "the mouse suddenly woke up and drank it"
  329. 913 print "and--wait a minute--the mouse is"
  330. 914 print "speaking.  it's reading some ancient"
  331. 915 print "words written in the embroidery of the"
  332. 916 print "pillow--and there's a secret door,"
  333. 917 print "beginning to glow brightly--it's the"
  334. 918 print "treasure room!  let's go in!"c$c$"(press a key)"
  335. 919 gosub 990:ds$="":return
  336. 920 print "[147]"dl$"there's a crack in one foundation stone"
  337. 921 print "and if you just pry a little with the"
  338. 922 print "butcher knife--yes, that's it.  get yourback into it."c$
  339. 923 print "you did it!  we can crawl under here andget inside.":print
  340. 924 print "(press a key)":ds$="":gosub 990:return
  341. 925 pr=5:xr=xx
  342. 926 ds$="you can't get through with the elephant.i thought you knew that."
  343. 927 ds$=ds$+c$+"only the main gate will let us pass."
  344. 928 return
  345. 937 rem
  346. 938 rem victory handler
  347. 939 rem
  348. 940 print "[147]we made it!":print:print "we're outside the castle with the"
  349. 941 print "emerald elephant of cipangu.  now you"
  350. 942 print "can see again, and i have recovered my"
  351. 943 print "true form.  i know i'm incredibly good-"
  352. 944 print "looking, but don't bother asking me for"
  353. 945 print "a date--you're fine for exploring"
  354. 946 print "castles, but i'm engaged to marry"
  355. 947 print "somebody with royal blood and a fortune"
  356. 948 print "bigger than the national debt.  you've"
  357. 949 print "been sweet, though.  thanks a bunch!":print:print "bye!"
  358. 950 poke 198,0:end
  359. 967 rem
  360. 968 rem randomly choose location of treasure room
  361. 969 rem
  362. 970 r=int(10*rnd(9)):if r>2 then r=3
  363. 971 if r=1 then r=0
  364. 972 on r goto 975,980,985
  365. 975 x=2+int(2*rnd(9)):rd(10,x)=14:return
  366. 980 rd(12,6)=14:return
  367. 985 x=1+int(8*rnd(9)):r=13:if rd(r,x)=55 then rd(r,x)=14:return
  368. 986 goto 985
  369. 990 a=peek(197):if a=64 then 990
  370. 995 cm=ks(a):return
  371. 997 rem
  372. 998 rem set up command word array
  373. 999 rem
  374. 1000 for i=0 to 16:read a$:cw$(i)=a$:next
  375. 1010 data "what?","north","south","east","west","up","down","in","out","back"
  376. 1015 data "take","leave","peer","got?","quit","help","help"
  377. 1047 rem
  378. 1048 rem set up keystroke array
  379. 1049 rem
  380. 1050 for i=0 to 64:ks(i)=0:next
  381. 1055 for i=1 to 16:read a:ks(a)=i:next
  382. 1060 data 39,13,14,9,30,18,33,38,28,22,42,41,26,62,29,55
  383. 1097 rem
  384. 1098 rem set up rd (room direction table) and rn$ (room name table)
  385. 1099 rem
  386. 1100 for i=1 to 14:read a$:rn$(i)=a$:for j=1 to 8:read a:rd(i,j)=a:next:next
  387. 1110 data "castle main gate",52,53,3,2,51,50,53,50
  388. 1115 data "meadow west of castle",1,4,51,52,51,50,51,50
  389. 1120 data "ledge east of castle",1,54,54,51,51,51,51,50
  390. 1125 data "grove south of castle",51,54,54,2,51,56,53,50
  391. 1130 data "kitchen",6,4,9,6,50,13,9,6
  392. 1135 data "courtyard",7,5,9,12,7,5,9,7
  393. 1140 data "gatehouse",56,6,8,8,8,6,6,56
  394. 1145 data "on the walls",7,10,10,7,57,51,7,50
  395. 1150 data "great hall",6,50,50,5,10,13,5,6
  396. 1155 data "count's chamber",8,55,55,8,11,9,50,8
  397. 1160 data "tower top",54,54,54,54,57,10,50,50
  398. 1165 data "the stables",50,50,6,50,50,55,50,6
  399. 1170 data "the dungeons",55,55,55,55,9,55,50,50
  400. 1175 data "treasure room",50,50,50,50,50,50,50,50
  401. 1197 rem
  402. 1198 rem set up rn$ values for illegal movement directions
  403. 1199 rem
  404. 1200 for i=50 to 57:read a$:rn$(i)=a$:next
  405. 1210 data "sorry, but we can't go that way"
  406. 1215 data "it's too steep for us to climb"
  407. 1220 data "we'll just get lost if we wander in the woods"
  408. 1225 data "i'm knocking, but nobody answers"
  409. 1230 data "are you trying to get us killed?"
  410. 1235 data "i searched there, found nothing, and    came back"
  411. 1240 data "we don't have what it takes to get in   there"
  412. 1245 data "up from here?  do you think you can fly?"
  413. 1297 rem
  414. 1298 rem set up the "thing" table by naming objects and putting them in rooms
  415. 1299 rem
  416. 1300 for i=0 to 9:read a$,b$:tn$(i)=a$:ts$(i)=b$:next
  417. 1310 data "a golden key","key","a loaf of rye bread","bread"
  418. 1315 data "a butcher knife","knife","a pocket sundial","sundial"
  419. 1320 data "a delicately embroidered pillow","pillow"
  420. 1325 data "a limp, motionless mouse","mouse"
  421. 1330 data "a parchment codex","codex","an orange rind","rind"
  422. 1335 data "a flagon of ale","flagon"
  423. 1340 data "the emerald elephant of cipangu","elephant"
  424. 1347 rem
  425. 1348 rem put each thing in its room
  426. 1349 rem
  427. 1350 for i=0 to 9:read a:tl(i)=a:next
  428. 1355 data 3,5,4,6,10,13,9,11,7,14
  429. 1990 return
  430.